package com.example.administrator.yuejian_2.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian_2.R;
import com.example.administrator.yuejian_2.bean.MasterAnswerBean;
import com.example.administrator.yuejian_2.viewholder.ManswerVH;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/10/10.
 */

public class ManswerAdapter extends RecyclerView.Adapter {
    private List<MasterAnswerBean> answerList = new ArrayList<>();
    private Context context;
    private LayoutInflater layoutInflater;

    public ManswerAdapter (Context context,List<MasterAnswerBean> answerList){
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        this.answerList.addAll(answerList);

    }



    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_manswer,parent,false);
        ManswerVH holder = new ManswerVH(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ManswerVH anholder = (ManswerVH) holder;
        MasterAnswerBean answerBean = answerList.get(position);

        String username = answerBean.getU_name();
        anholder.uname.setText(username);

        String maname = answerBean.getC_name();
        anholder.mname.setText(maname);

        String uquestion = answerBean.getAn_ques();
        anholder.uques.setText(uquestion);

        String manswe = answerBean.getAn_swer();
        anholder.manswer.setText(manswe);


    }

    @Override
    public int getItemCount() {
        return answerList.size();
    }
}
